<template>
  <div class="artificialReplenishment">
    <el-card class="box-card">
      <div slot="header" class="clearfix">
        <span style="line-height: 36px;">人工驱动补货</span>
        <el-button style="float: right;" type="primary" @click="dialogOpen()">新增</el-button>
      </div>
      <s-table
        :table="table"
        :expand="false"
        @http="tableWatch">
        <el-table-column
          fixed="right"
          align="center"
          slot="operation"
          class-name="operationMore"
          label="可用操作"
          width="150">
          <template slot-scope="s">
            <el-button type="info" size="mini" @click="dialogSearchOpen(s.row)" >查看</el-button>
            <el-button type="info" size="mini" @click="dialogReplenishmentOpen(s.row)">查看补货任务</el-button>
            <el-button type="info" size="mini" @click="tableCancel(s.row)" v-if="s.row.zt === 1">取消补货</el-button>
            <el-button type="info" size="mini" @click="dialogIssuedOpen(s.row)" v-if="s.row.zt === 1 && s.row.sczt ===0">下发补货任务</el-button>
            <el-button type="info" size="mini"  @click="dialogEditOpen(s.row)" v-if="s.row.zt === 0">修改</el-button>
            <el-button type="info" size="mini" @click="tableCreate(s.row)" v-if="s.row.zt === 0">生成补货单</el-button>
            <el-button type="danger"  size="mini" @click="tableDelete(s.row)" v-if="s.row.zt === 0">删除</el-button>
            <!--<el-button type="info"  size="mini" @click="tableExport(s.row)">导出</el-button>-->
            <!--<el-tooltip placement="top" v-if="s.row.zt !== 2">-->
            <!--<el-tooltip placement="top">-->
              <!--<div slot="content">更多可用操作</div>-->
              <!--<el-popover-->
                <!--popper-class="demo-table-expand"-->
                <!--placement="right"-->
                <!--title="更多可用操作"-->
                <!--trigger="click">-->
                <!--<slot name="content">-->
                  <!---->
                  <!--&lt;!&ndash;<el-button type="info" size="mini" @click="tableConfirm(s.row)" v-if="s.row.zt === 1 && s.row.sczt !== '1'">确认补货单</el-button>&ndash;&gt;-->
                <!--</slot>-->
                <!--<el-button slot="reference" type="info" icon="more" :plain="true" size="mini" class="__reference"></el-button>-->
              <!--</el-popover>-->
            <!--</el-tooltip>-->
          </template>
        </el-table-column>
        <el-form-item slot="multiSelect" label="多选操作" prop="multiSelect" v-if="table.multiSelect">
          <el-row>
            <el-col :span="8">
              <el-button size="small" type="danger" @click="tableDelete('')">多选删除</el-button>
            </el-col>
            <!--<el-col :span="8">-->
              <!--<el-button size="small" type="info" @click="tableCreate('')">多选生成</el-button>-->
            <!--</el-col>-->
            <!--<el-col :span="8">-->
              <!--<el-button size="small"  type="info" @click="tableConfirm('')">确认补货</el-button>-->
            <!--</el-col>-->
            <el-col :span="8">
              <el-button size="small" type="info" @click="tableExport('')">多选导出</el-button>
            </el-col>
          </el-row>
        </el-form-item>
        <el-row>
          <el-col :xs="24" :lg="{span: 4, offset: 0}">
            <el-form-item label="补货单号" prop="bh">
              <el-input type="text"
                        class="input"
                        v-model="autoVue_table_bh"
                        placeholder="补货单号" spellcheck="false" auto-capitalize="off" auto-complete="off"
                        auto-correct="off"></el-input>
            </el-form-item>
          </el-col>
          <el-col :xs="24" :lg="{span: 4, offset: 1}">
            <el-form-item label="补货状态" prop="zt">
              <el-select v-model="autoVue_table_zt"
                         placeholder="补货状态">
                <el-option
                  label="全部"
                  value=""></el-option>
                <el-option
                  v-for="item in ARTIFICIALREPLENISHMENT.zt"
                  :key="item.dictionaryid"
                  :label="item.value"
                  :value="item.dictionaryid">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :xs="24" :lg="{span: 4, offset: 1}">
            <el-form-item label="创建时间" prop="cjsj">
              <el-date-picker
                v-model="autoVue_table_cjsj"
                type="daterange"
                placeholder="选择日期范围">
              </el-date-picker>
            </el-form-item>
          </el-col>
        </el-row>
      </s-table>
    </el-card>
    <s-dialog :dialog="dialog" :close="dialogInit">
      <p slot="title">{{dialog.title}}补货单</p>
      <s-form :form="formDialog" ref="formDialog">
        <el-row>
          <el-col :xs="24" :lg="{span: 11, offset: 0}">
            <el-form-item prop="bh" label="补货单号">
              <el-input
                disabled
                type="text"
                v-model="formDialog.bh"
                placeholder="补货单号"></el-input>
            </el-form-item>
          </el-col>
          <el-col :xs="24" :lg="{span: 11, offset: 1}">
            <el-form-item prop="bz" label="备注">
              <el-input
                type="text"
                v-model="formDialog.bz"
                placeholder="备注"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
      </s-form>
      <div class="__table" v-if="this.dialog.title ==='新增'">
        <el-button @click="dialogAddMxOpen('add')" class="__table_button"><i class="el-icon-plus"></i></el-button>
        </div>
      <s-table
        :table="tableAdd" ref="tableAdd" @http="tableWatch" :control="false" v-if="this.dialog.title ==='新增'" :pagination="false">
        <el-table-column
          fixed="right"
          align="center"
          slot="operation"
          class-name="operationMore"
          label="可用操作"
          width="120">
          <template slot-scope="s">
            <el-button type="info" size="mini" icon="edit" @click="dialogAddMxEditOpen(s.row)"></el-button>
            <el-button type="danger" icon="delete" size="mini" @click="tableAddMxDelete(s.$index)"></el-button>
          </template>
        </el-table-column>
      </s-table>
      <el-button slot="footer" type="success"  @click="dialogSave">保存</el-button>
    </s-dialog>
    <s-dialog :dialog="dialogAddMx" :close="dialogAddMxInit">
      <p slot="title">{{dialogAddMx.title}}补货单明细</p>
      <s-table :table="tableAddMx" ref="tableAddMx" @http="tableWatch" :multiSelect="true">
        <el-form-item label="货品编号" prop="hpbh">
          <el-input type="text"
                    class="input"
                    v-model="autoVue_tableAddMx_hpbh"
                    placeholder="货品编号" spellcheck="false" auto-capitalize="off" auto-complete="off"
                    auto-correct="off"></el-input>
        </el-form-item>
        <el-form-item label="货品名称" prop="hpmc">
          <el-input type="text"
                    class="input"
                    v-model="autoVue_tableAddMx_hpmc"
                    placeholder="货品名称" spellcheck="false" auto-capitalize="off" auto-complete="off"
                    auto-correct="off"></el-input>
        </el-form-item>
      </s-table>
      <el-button slot="footer" @click="dialogAddMxSave">保存</el-button>
    </s-dialog>
    <s-dialog :dialog="dialogAddMxEdit":close="dialogAddMxEditInit">
      <p slot="title">{{dialogAddMxEdit.title}}明细</p>
      <s-form :form="formDialogAddMxEdit" ref="formDialogAddMxEdit">
        <el-row>
          <el-col :xs="24" :lg="{span: 11, offset: 0}">
            <el-form-item prop="hpbh" label="货品编号">
              <el-input
                type="text"
                disabled
                v-model="formDialogAddMxEdit.hpbh"
                placeholder="货品编号"></el-input>
            </el-form-item>
          </el-col>
          <el-col :xs="24" :lg="{span: 11, offset: 1}">
            <el-form-item prop="hpmc" label="货品名称">
              <el-input
                type="text"
                disabled
                v-model="formDialogAddMxEdit.hpmc"
                placeholder="货品编号"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :xs="24" :lg="{span: 11, offset: 0}">
            <el-form-item prop="kwmc" label="补货库位">
              <el-input
                type="text"
                disabled
                v-model="formDialogAddMxEdit.kwmc"
                placeholder="补货库位"></el-input>
            </el-form-item>
          </el-col>
          <el-col :xs="24" :lg="{span: 11, offset: 1}">
            <el-form-item prop="ccqsl" label="存储区可用数量">
              <el-input
                type="text"
                disabled
                v-model="formDialogAddMxEdit.ccqsl"
                placeholder="存储区可用数量"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :xs="24" :lg="{span: 11, offset: 0}">
            <el-form-item prop="sl" label="补货数量主">
              <el-input-number
                :min="0" :max="parseInt(formDialogAddMxEdit.ccqsl)"
                v-model="formDialogAddMxEdit.sl"></el-input-number>
            </el-form-item>
          </el-col>
        </el-row>
      </s-form>
      <el-button slot="footer" @click="dialogAddMxEditSave">保存</el-button>
    </s-dialog>
    <s-dialog :dialog="dialogSearch" :close="dialogSearchInit" :closeTip="false">
      <p slot="title">{{dialogSearch.title}}明细</p>
      <div class="__table" v-if="this.dialog.title ==='新增'">
        <el-button @click="dialogSearchMxOpen('add')" class="__table_button" v-if="dialogSearch.row.zt == 0"><i class="el-icon-plus"></i></el-button>
      </div>
      <s-table :table="tableSearch" ref="tableSearch" @http="tableWatch" :control="dialogSearch.row.zt !=0" :pagination="false">
        <el-table-column
          v-if="dialogSearch.row.zt == 0"
          fixed="right"
          align="center"
          slot="operation"
          class-name="operationMore"
          label="操作"
          width="80">
          <template slot-scope="s">
            <el-button type="info" size="mini"  @click="dialogSearchEditOpen(s.row)">修改</el-button>
            <el-button type="danger"  size="mini" @click="tableSearchDelete(s.row)">删除</el-button>
          </template>
        </el-table-column>
      </s-table>
      <!--<el-button slot="footer" type="success"  @click="dialogSearchSave">确认</el-button>-->
    </s-dialog>
    <s-dialog :dialog="dialogSearchMx" :close="dialogSearchMxInit">
      <p slot="title">{{dialogSearchMx.title}}补货单明细</p>
      <s-table :table="tableSearchMx" ref="tableSearchMx" @http="tableWatch" :multiSelect="true">
        <el-form-item label="货品编号" prop="hpbh">
          <el-input type="text"
                    class="input"
                    v-model="autoVue_tableSearchMx_hpbh"
                    placeholder="货品编号" spellcheck="false" auto-capitalize="off" auto-complete="off"
                    auto-correct="off"></el-input>
        </el-form-item>
        <el-form-item label="货品名称" prop="hpmc">
          <el-input type="text"
                    class="input"
                    v-model="autoVue_tableSearchMx_hpmc"
                    placeholder="货品名称" spellcheck="false" auto-capitalize="off" auto-complete="off"
                    auto-correct="off"></el-input>
        </el-form-item>
      </s-table>
      <el-button slot="footer" @click="dialogSearchMxSave">保存</el-button>
    </s-dialog>
    <s-dialog :dialog="dialogSearchEdit":close="dialogSearchEditInit">
      <p slot="title">{{dialogSearchEdit.title}}明细</p>
      <s-form :form="formDialogSearchEdit" ref="formDialogSearchEdit">
        <el-row>
          <el-col :xs="24" :lg="{span: 11, offset: 0}">
            <el-form-item prop="hpbh" label="货品编号">
              <el-input
                type="text"
                disabled
                v-model="formDialogSearchEdit.hpbh"
                placeholder="货品编号"></el-input>
            </el-form-item>
          </el-col>
          <el-col :xs="24" :lg="{span: 11, offset: 1}">
            <el-form-item prop="hpmc" label="货品名称">
              <el-input
                type="text"
                disabled
                v-model="formDialogSearchEdit.hpmc"
                placeholder="货品编号"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :xs="24" :lg="{span: 11, offset: 0}">
            <el-form-item prop="kwmc" label="补货库位">
              <el-input
                type="text"
                disabled
                v-model="formDialogSearchEdit.kwmc"
                placeholder="补货库位"></el-input>
            </el-form-item>
          </el-col>
          <el-col :xs="24" :lg="{span: 11, offset: 1}">
            <el-form-item prop="ccqsl" label="存储区可用数量">
              <el-input
                type="text"
                disabled
                v-model="formDialogSearchEdit.ccqsl"
                placeholder="存储区可用数量"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :xs="24" :lg="{span: 11, offset: 0}">
            <el-form-item prop="sl" label="补货数量主">
              <el-input-number
                :min="0" :max="parseInt(formDialogSearchEdit.ccqsl)"
                v-model="formDialogSearchEdit.sl"></el-input-number>
            </el-form-item>
          </el-col>
        </el-row>
      </s-form>
      <el-button slot="footer" @click="dialogSearchEditSave">保存</el-button>
    </s-dialog>
    <s-dialog :dialog="dialogEdit" :close="dialogEditInit">
      <p slot="title">{{dialogEdit.title}}补货单</p>
      <s-form :form="formDialogEdit" ref="formDialogEdit">
        <el-row>
          <el-col :xs="24" :lg="{span: 11, offset: 0}">
            <el-form-item prop="bh" label="补货单号">
              <el-input
                type="text"
                v-model="formDialogEdit.bh"
                placeholder="补货单号"></el-input>
            </el-form-item>
          </el-col>
          <el-col :xs="24" :lg="{span: 11, offset: 1}">
            <el-form-item prop="bz" label="备注">
              <el-input
                type="text"
                v-model="formDialogEdit.bz"
                placeholder="备注"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
      </s-form>
      <el-button slot="footer" type="success"  @click="dialogEditSave">保存</el-button>
    </s-dialog>
    <s-dialog :dialog="dialogIssued" :close="dialogIssuedInit">
      <p slot="title">{{dialogIssued.title}}补货任务</p>
      <s-form :form="formDialogIssued" ref="formDialogIssued">
        <el-row>
          <el-col :xs="24" :lg="{span: 11, offset: 0}" class="">
            <el-form-item prop="account" label="账户类型">
              <el-select v-model="formDialogIssued.account" placeholder="请选择">
                <el-option
                  v-for="item in SHELVESTASK.account"
                  :key="item.dictionaryid"
                  :label="item.value"
                  :value="item.dictionaryid">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :xs="24" :lg="{span: 11, offset: 1}" class="">
            <el-form-item prop="ryid" label="人员">
              <el-select v-model="formDialogIssued.ryid"
                         filterable
                         @change="dialogRemoteryid"
                         placeholder="请输入人员名称">
                <el-option
                  v-for="item in dialogIssued.wmsqualityinspectionlist"
                  :key="item.id"
                  :label="item.name"
                  :value="item.id">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
      </s-form>
      <el-button slot="footer" @click="dialogIssuedSave">保存</el-button>
    </s-dialog>
    <s-dialog :dialog="dialogReplenishment" :close="dialogReplenishmentInit">
      <s-table :table="tableReplenishment" ref="tableReplenishment" @http="tableWatch"></s-table>
    </s-dialog>
  </div>
</template>

<script>
  import {AutoVue, AutoPromise} from '~/plugins/Tools';

  function __form () {
    return {
      bh: { value: '', rule: [ '' ], cRemarks: '' },
      bz: { value: '', rule: [ '' ], cRemarks: '' },
    };
  }
  function __formAddMx () {
    return {
      bhid: { value: '', rule: [ 'vNull' ], cRemarks: '' },
      mcid: { value: '', rule: [ 'vNull' ], cRemarks: '' },
    };
  }
  function __formAddMxEdit () {
    return {
      kwlx: { value: '', rule: [], cRemarks: '' },
      kwmc: { value: '', rule: [], cRemarks: '' },
      kwid: { value: '', rule: [], cRemarks: '' },
      hpbh: { value: '', rule: [], cRemarks: '' },
      hpmc: { value: '', rule: [], cRemarks: '' },
      ccqsl: { value: '', rule: [], cRemarks: '' },
      sl: { value: '', rule: [], cRemarks: '' },
      jhqsl: { value: '', rule: [], cRemarks: '' },
      bhsx: { value: '', rule: [], cRemarks: '' },
    };
  }
  function __formSearchEdit () {
    return {
      hpbh: { value: '', rule: [], cRemarks: '' },
      hpmc: { value: '', rule: [], cRemarks: '' },
      ccqsl: { value: '', rule: [], cRemarks: '' },
      kwmc: { value: '', rule: [], cRemarks: '' },
      sl: { value: '', rule: [], cRemarks: '' },
      bhsx: { value: '', rule: [], cRemarks: '' },
    };
  }
  function __formEdit () {
    return {
      bh: { value: '', rule: [ '' ], cRemarks: '' },
      bz: { value: '', rule: [ '' ], cRemarks: '' },
    };
  }
  function __formIssued () {
    return {
      account: { value: '', rule: [ 'vNull__change' ] },
      ryid: { value: '', rule: [ 'vNull__change' ] },
    };
  }
  export default AutoVue({
    name: 'stock_artificialReplenishment-FEcarWms',
    head: {
      'title': '人工驱动补货管理',
      'meta': [
        { 'hid': 'description', 'name': 'description', 'content': '乐速科技平台 人工驱动补货 查看人工驱动补货信息' },
      ],
    },
    store: ['ARTIFICIALREPLENISHMENT', 'DICTIONARY_artificialReplenishment', 'DICTIONARY_shelvesTask', 'SHELVESTASK'],
    data: {
      table: {
        column:
          [
            { label: '补货单号',
              prop: 'bh',
              minWidth: '0px',
              cRemarks: '',
              search: true },
            { label: '创建时间',
              prop: 'cjsj',
              minWidth: '0px',
              cRemarks: '',
              type: 'DateRange',
              formatter: (row, column) => {
                return this.a.methods.formatterTime(row[column.property || column], 6);
              },
              search: true },
            { label: '创建人',
              prop: 'cjr',
              minWidth: '70px',
              cRemarks: '',
              search: false },
            { label: '生成时间',
              prop: 'scsj',
              minWidth: '0px',
              cRemarks: '',
              formatter: (row, column) => {
                return this.a.methods.formatterTime(row[column.property || column], 6);
              },
              search: true },
            { label: '确认时间',
              prop: 'qrsj',
              minWidth: '0px',
              cRemarks: '',
              formatter: (row, column) => {
                return this.a.methods.formatterTime(row[column.property || column], 6);
              },
              search: true },
            { label: '状态',
              prop: 'show_zt',
              minWidth: '0px',
              cRemarks: ' 0：初始 1：已生成 2：已确认 3：作废',
              search: true },
            { label: '生成状态',
              prop: 'show_sczt',
              minWidth: '0px',
              cRemarks: ' 0：初始 1：已生成',
              search: false },
            { label: '补货单备注',
              prop: 'bz',
              minWidth: '0px',
              cRemarks: '',
              search: false },
          ],
        url: '/wmsartificialreplenishment/list',
        key: 'id',
        tableColumn: 7,
      },
      formDialog: __form(),
      dialog: {
        title: '新增',
        row: {},
        size: 'large',
        message: {},
      },
      tableAdd: {
        column: [
          { label: '货品编号',
            prop: 'hpbh',
            minWidth: '0px',
            cRemarks: '',
            search: false },
          { label: '货品名称',
            prop: 'hpmc',
            minWidth: '0px',
            cRemarks: '',
            search: false },
          { label: '单位',
            prop: 'dw',
            minWidth: '0px',
            cRemarks: '',
            search: false },
          { label: '补货库位',
            prop: 'kwmc',
            minWidth: '0px',
            cRemarks: '',
            search: false },
          { label: '补货数量主',
            prop: 'sl',
            minWidth: '0px',
            cRemarks: '',
            search: false },
        ],
        tableColumn: 5,
        muti: false,
        key: 'id',
      },
      dialogAddMx: {
        title: '新增',
        size: 'large',
      },
      formDialogAddMx: __formAddMx(),
      tableAddMx: {
        column: [
          { label: '库位类型',
            prop: 'show_kwlx',
            minWidth: '0px',
            cRemarks: '',
            search: false },
          { label: '库位名称',
            prop: 'kwmc',
            minWidth: '0px',
            cRemarks: '',
            search: false },
          { label: '单位类型',
            prop: 'dw',
            minWidth: '80px',
            cRemarks: '',
            search: false },
          { label: '货品编号',
            prop: 'hpbh',
            minWidth: '0px',
            cRemarks: '',
            search: true },
          { label: '货品名称',
            prop: 'hpmc',
            minWidth: '0px',
            cRemarks: '',
            search: true },
          { label: '存储区数量',
            prop: 'ccqsl',
            minWidth: '80px',
            cRemarks: '',
            search: false },
          { label: '补货数量',
            prop: 'sl',
            minWidth: '0px',
            cRemarks: '',
            elInputNumber: {
              min: 1,
              controls: [false, true],
              max: 'ccqsl',
            },
            search: false },
          { label: '拣货区数量',
            prop: 'jhqsl',
            minWidth: '80px',
            cRemarks: '',
            search: false },
          { label: '补货上限',
            prop: 'bhsx',
            minWidth: '0px',
            cRemarks: '',
            search: false },
        ],
        key: 'id',
        url: '/wmsartificialreplenishment/getGoods',
        tableColumn: 9,
        muti: false,
      },
      dialogAddMxEdit: {
        title: '编辑',
        row: {},
      },
      formDialogAddMxEdit: __formAddMxEdit(),
      dialogSearch: {
        title: '查看',
        size: 'large',
        row: {},
        option: {
          bhid: '',
          ckid: '',
          hpid: '',
          hzid: '',
          id: '',
          kwid: '',
          sl: '',
          xdwsl: '',
        },
      },
      tableSearch: {
        column: [
          { label: '货品编号',
            prop: 'hpbh',
            minWidth: '0px',
            cRemarks: '',
            search: false },
          { label: '货品名称',
            prop: 'hpmc',
            minWidth: '0px',
            cRemarks: '',
            search: false },
          { label: '补货库位',
            prop: 'kwmc',
            minWidth: '0px',
            cRemarks: '',
            search: false },
          { label: '单位',
            prop: 'dw',
            minWidth: '0px',
            cRemarks: '',
            search: false },
          { label: '存储区可用数量',
            prop: 'ccqsl',
            minWidth: '0px',
            cRemarks: '',
            search: false },
          { label: '补货数量主',
            prop: 'sl',
            minWidth: '0px',
            cRemarks: '',
            search: false },
        ],
        option: {
          ids: '',
        },
        tableColumn: 6,
        url: '/wmsartificialreplenishment/getDetailList',
        muti: false,
        key: 'id',
      },
      dialogSearchMx: {
        title: '新增',
        size: 'large',
        row: {},
      },
      tableSearchMx: {
        column: [
          { label: '库位类型',
            prop: 'show_kwlx',
            minWidth: '0px',
            cRemarks: '',
            search: false },
          { label: '库位名称',
            prop: 'kwmc',
            minWidth: '0px',
            cRemarks: '',
            search: false },
          { label: '单位类型',
            prop: 'dw',
            minWidth: '80px',
            cRemarks: '',
            search: false },
          { label: '货品编号',
            prop: 'hpbh',
            minWidth: '0px',
            cRemarks: '',
            search: true },
          { label: '货品名称',
            prop: 'hpmc',
            minWidth: '0px',
            cRemarks: '',
            search: true },
          { label: '存储区数量',
            prop: 'ccqsl',
            minWidth: '80px',
            cRemarks: '',
            search: false },
          { label: '补货数量',
            prop: 'sl',
            minWidth: '0px',
            cRemarks: '',
            elInputNumber: {
              min: 1,
              controls: [false, true],
              max: 'ccqsl',
            },
            search: false },
          { label: '拣货区数量',
            prop: 'jhqsl',
            minWidth: '80px',
            cRemarks: '',
            search: false },
          { label: '补货上限',
            prop: 'bhsx',
            minWidth: '0px',
            cRemarks: '',
            search: false },
        ],
        url: '/wmsartificialreplenishment/getGoods',
        tableColumn: 9,
        muti: false,
        key: 'id',
      },
      dialogSearchEdit: {
        title: '编辑',
      },
      formDialogSearchEdit: __formSearchEdit(),
      dialogEdit: {
        title: '编辑',
        row: {},
      },
      formDialogEdit: __formEdit(),
      dialogIssued: {
        title: '下发',
        wmsqualityinspectionlist: '',
        row: {},
        ryid: '',
      },
      formDialogIssued: __formIssued(),
      dialogReplenishment: {
        title: '查看',
        size: 'large',
      },
      tableReplenishment: {
        column: [
          { label: '货品编号',
            prop: 'hpbh',
            minWidth: '0px',
            cRemarks: '',
            search: false },
          { label: '货品名称',
            prop: 'hpmc',
            minWidth: '0px',
            cRemarks: '',
            search: false },
          { label: '包装数量',
            prop: 'zdwsl',
            minWidth: '0px',
            cRemarks: '',
            search: false },
          { label: '包装描述',
            prop: 'ms',
            minWidth: '0px',
            cRemarks: '',
            search: false },
          { label: '补货出库位',
            prop: 'bhckw',
            minWidth: '0px',
            cRemarks: '',
            search: false },
          { label: '补货数量',
            prop: 'bhsl',
            minWidth: '0px',
            cRemarks: '',
            search: false },
          { label: '托盘码',
            prop: 'lpn',
            minWidth: '0px',
            cRemarks: '',
            search: false },
        ],
        option: {
          bhlx: '',
          bhid: '',
        },
        url: '/wmspdareplenishment/list',
        tableColumn: 7,

      },
    },
    transition: 'slide-fade',
    methods: {
      tableCancel (row) {
        this.$confirm('您将进行取消补货的操作', '确认取消补货？', {
          confirmButtonText: '是',
          cancelButtonText: '否',
          type: 'warning',
        })
          .then(async _ => {
            try {
              await this.post('/wmsartificialreplenishment/cancelBhd', {
                id: row.id,
              });
              this.tableWatch('table');
            } catch (err) {
              console.log(err);
            }
          })
          .catch(_ => {
          });
      },
      tableExport (row) {
        let tableRef = 'table';

        let ids = [];
        if (row) {
          ids.push(row.id);
        } else {
          this[tableRef].multipleSelection.forEach(item => {
            ids.push(item.id);
          });
        }
        this.$confirm('您将导出人工驱动补货。', '确认导出？', {
          confirmButtonText: '是',
          cancelButtonText: '否',
          type: 'warning',
        })
          .then(async _ => {
            try {
              let option = Object.assign({}, this['autoVue_' + tableRef]);
              await this.p({
                url: '/wmsartificialreplenishment/getOutPutList',
                method: 'post',
                responseType: 'blob',
                data: {
                  ids,
                  ...option,
                },
              });
            } catch (err) {
              console.log(err);
            }
          })
          .catch(_ => {
          });
      },
      tableConfirm (row) {
        this.$confirm('您将进行确认补货的操作', '确认补货？', {
          confirmButtonText: '是',
          cancelButtonText: '否',
          type: 'warning',
        })
          .then(async _ => {
            try {
              await this.post('/wmsartificialreplenishment/confirmOrder', {
                id: row.id,
              });
              this.tableWatch('table');
            } catch (err) {
              console.log(err);
            }
          })
          .catch(_ => {
          });
      },
      tableDelete (row) {
        let ids = [];
        if (row) {
          ids.push(row.id);
        } else {
          if (this.table.multipleSelection.length < 1) {
            return this.$alert('您还未选择，请您至少选择一个！', '提示');
          }
          this.table.multipleSelection.forEach(item => {
            ids.push(item.id);
          });
        }
        this.$confirm('您将删除选择的数据', '确认删除？', {
          confirmButtonText: '是',
          cancelButtonText: '否',
          type: 'warning',
        })
          .then(async _ => {
            try {
              await this.post('/wmsartificialreplenishment/delete', {
                ids,
              });
              this.tableWatch('table');
            } catch (err) {
              console.log(err);
            }
          })
          .catch(_ => {
          });
      },
      tableCreate (row) {
        let ids = [];
        if (row) {
          ids.push(row.id);
        } else {
          if (this.table.multipleSelection.length < 1) {
            return this.$alert('您还未选择，请您至少选择一个！', '提示');
          }
          this.table.multipleSelection.forEach(item => {
            ids.push(item.id);
          });
        }
        this.$confirm('您将选择的数据生成补货单', '确认生成补货单？', {
          confirmButtonText: '是',
          cancelButtonText: '否',
          type: 'warning',
        })
          .then(async _ => {
            try {
              await this.post('/wmsartificialreplenishment/generateReplenishment', {
                ids,
              });
              this.tableWatch('table');
            } catch (err) {
              console.log(err);
            }
          })
          .catch(_ => {
          });
      },
      dialogInit () {
        this.formDialog = {
          ...this.formDialog,
          ...this.ObjectClone(__form()),
        };
        this.resetFields('formDialog');
        this.tableClear('tableAdd');
      },
      async dialogOpen () {
        if (this.table.data.length > 0) {
          let bool = true;
          let ids = [];
          this.table.data.forEach(async item => {
            ids.push(item.zt);
            if (this.table.data.length > 0 && item.zt !== 2) {
              this.$alert('请把补货单据生成确认后才可以新增下一条补货单据', '提示');
              bool = false;
            } else {
              if (bool) {
                let bh = await this.get('/wmsartificialreplenishment/getBhbh');
                this.formDialog.bh = bh;
                this.dialog.visible = true;
              }
            }
          });
        } else {
          let bh = await this.get('/wmsartificialreplenishment/getBhbh');
          this.formDialog.bh = bh;
          this.dialog.visible = true;
        }
      },
      dialogSave () {
        if (this.dialog.title === '新增') {
          this.VALIDATE('formDialog', async option => {
            // ...:扩展运算符 将一个数组的参数序列
            let json = {
              wardList: this.tableAdd.data,
              ...option,
            };
            let sum = 0;
            try {
              await this.post('/wmsartificialreplenishment/add', json);
              this.dialogInit();
              this.tableWatch('table');
              this.dialog.visible = false;
            } catch (err) {
              console.log(err);
            }
          });
        }
      },
      tableAddDelete (index) {
        this.$confirm('您将删除选择的明细货品编号为:', '确认删除？', {
          confirmButtonText: '是',
          cancelButtonText: '否',
          type: 'warning',
        })
          .then(_ => {
            this.tableAdd.data.splice(index, 1);
          });
      },
      dialogAddMxInit () {
        this.tableClear('tableAddMx');
      },
      dialogAddMxOpen () {
        this.dialogAddMx.visible = true;
      },
      tableAddEdit () {},
      dialogAddMxSave () {
        if (this.dialogAddMx.title === '新增') {
          if (this.tableAddMx.multipleSelection.length < 1) {
            return this.$alert('请至少选择一个', '提示');
          } else {
            let sum = 0;
            let bool = true;
            this.tableAddMx.multipleSelection.forEach(item => {
              this.tableAdd.data.forEach((value, index) => {
                if (item.dw === value.dw && item.hpbh === value.hpbh) {
                  this.$alert('已经存在：' + value.dw + '货品：' + value.hpbh, '提示');
                  this.dialogAddMx.visible = true;
                  bool = false;
                }
              });
              sum += item.sl;
              if (parseInt(sum) > parseInt(item.ccqsl)) {
                bool = false;
                return this.$alert('输入的补货数量不能大于存储区可用数量:' + item.ccqsl, '提示');
              }
            });
            if (bool) {
              this.tableAddMx.multipleSelection.forEach(item => {
                this.tableAdd.data.push(item);
                this.dialogAddMxInit();
                this.dialogAddMx.visible = false;
              });
            }
          }
        }
      },
      tableAddMxDelete (index) {
        this.$confirm('您将删除选择的明细:', '确认删除？', {
          confirmButtonText: '是',
          cancelButtonText: '否',
          type: 'warning',
        })
          .then(_ => {
            this.tableAdd.data.splice(index, 1);
          });
      },
      dialogAddMxEditInit () {},
      dialogAddMxEditOpen (row) {
        this.formDialogAddMxEdit = {
          ...this.formDialogAddMxEdit,
          ...this.ObjectClone(__formAddMxEdit(), row),
        };
        this.dialogAddMxEdit.row = row;
        this.dialogAddMxEdit.visible = true;
      },
      dialogAddMxEditSave () {
        // 这个方法不执行，但是页面也没有报错 。原因是formDialogAddMxEdit中没有ref或者ref与formDialog的名称不一致
        this.VALIDATE('formDialogAddMxEdit', option => {
          for (let index in option) {
            if (option.hasOwnProperty(index)) {
              if (!option[index]) continue;
              this.dialogAddMxEdit.row[index] = option[index];
            }
          }
          this.dialogAddMxEditInit();
          this.dialogAddMxEdit.visible = false;
        });
      },
      tableSearchDelete (row) {
        let step = [];
        if (row) {
          step.push(row.id);
        }
        let ids = [];
        if (row) {
          ids.push(row.id);
        } else {
          if (this.tableSearch.multipleSelection.length < 1) {
            return this.$alert('您还未选择，请您至少选择一个！', '提示');
          }
          this.tableSearch.multipleSelection.forEach(item => {
            ids.push(item.id);
          });
        }
        this.$confirm('您将删除选择的数据', '确认删除？', {
          confirmButtonText: '是',
          cancelButtonText: '否',
          type: 'warning',
        })
          .then(async _ => {
            try {
              await this.post('/wmsartificialreplenishmentdetailed/delete', {
                'id': this.dialogSearch.row.id,
                'ids': step,
              });
              this.tableSearch.data = await this.post('/wmsartificialreplenishment/getDetailList', {
                ids: [row.bhid],
              });
            } catch (err) {
              console.log(err);
            }
          })
          .catch(_ => {
          });
      },
      dialogSearchInit () {},
      async dialogSearchOpen (row) {
        try {
          this.tableSearch.data = await this.post('/wmsartificialreplenishment/getDetailList', {
            ids: [row.bhid],
          });
        } catch (err) {
          console.log(err);
        }
        // console.log('row:' + row);
        // console.log('row:' + row.hpid);
        // console.log('row:' + row.bhid);
        // console.log('row.sl:' + row.sl);
        this.dialogSearch.row = row;
        console.log(this.dialogSearch.row.id);
        this.dialogSearch.visible = true;
      },
      async dialogSearchSave () {
        this.dialogSearch.visible = false;
      },
      dialogSearchMxInit () {
        this.tableClear('tableSearchMx');
      },
      dialogSearchMxOpen () {
        this.dialogSearchMx.visible = true;
      },
      async dialogSearchMxSave () {
        if (this.dialogSearchMx.title === '新增') {
          if (this.tableSearchMx.multipleSelection.length < 1) {
            return this.$alert('请至少选择一个', '提示');
          } else {
            let sum = 0;
            let bool = true;
            this.tableSearchMx.multipleSelection.forEach(item => {
              this.tableSearch.data.forEach((value, index) => {
                if (item.dw === value.dw && item.hpbh === value.hpbh) {
                  console.log(value.dw);
                  console.log(item.dw);
                  console.log(value.hpbh);
                  console.log(item.hpbh);
                  this.$alert('已经存在：' + value.dw + '货品：' + value.hpbh, '提示');
                  this.dialogSearchMx.visible = true;
                  bool = false;
                }
              });
              sum += item.sl;
              if (parseInt(sum) > parseInt(item.ccqsl)) {
                bool = false;
                return this.$alert('输入的补货数量不能大于存储区可用数量:' + item.ccqsl, '提示');
              }
            });
            if (bool) {
              try {
                this.tableSearchMx.multipleSelection.forEach(item => {
                  item.bhid = this.dialogSearch.row.id;
                });
                await this.post('/wmsartificialreplenishmentdetailed/add', this.tableSearchMx.multipleSelection);
                this.tableSearch.data = await this.post('/wmsartificialreplenishment/getDetailList', {
                  ids: [this.dialogSearch.row.bhid],
                });
                this.dialogSearchMxInit();
                this.dialogSearchMx.visible = false;
              } catch (err) {
                console.log(err);
              }
            }
          }
        }
      },
      dialogSearchEditInit () {},
      dialogSearchEditOpen (row) {
        this.formDialogSearchEdit = {
          ...this.formDialogSearchEdit,
          ...this.ObjectClone(__formSearchEdit(), row),
        };
        this.dialogSearchEdit.row = row;
        this.dialogSearchEdit.visible = true;
      },
      dialogSearchEditSave () {
        this.VALIDATE('formDialogSearchEdit', async option => {
          delete option.hpbh;
          delete option.hpmc;
          delete option.kwmc;
          delete option.ccqsl;
          option.id = this.dialogSearchEdit.row.id;
          try {
            await this.post('/wmsartificialreplenishmentdetailed/edit', option);
            this.tableSearch.data = await this.post('/wmsartificialreplenishment/getDetailList', {
              ids: [this.dialogSearch.row.bhid],
            });
            this.dialogSearchMxInit();
            this.dialogSearchEdit.visible = false;
          } catch (err) {
            console.log(err);
          }
        });
      },
      dialogEditInit () {},
      dialogEditOpen (row) {
        this.formDialogEdit = {
          ...this.formDialogEdit,
          ...this.ObjectClone(__formEdit(), row),
        };
        this.dialogEdit.row = row;
        this.dialogEdit.visible = true;
      },
      dialogEditSave () {
        this.VALIDATE('formDialogEdit', async option => {
          try {
            option.id = this.dialogEdit.row.id;
            await this.post('/wmsartificialreplenishment/edit', option);
            this.dialogInit();
            this.tableWatch('table');
            this.dialogEdit.visible = false;
          } catch (err) {
            console.log(err);
          }
        });
      },
      dialogIssuedInit () {
        this.formDialogIssued = {
          ...this.formDialogIssued,
          ...this.ObjectClone(__formIssued()),
        };
        this.resetFields('formDialogIssued');
      },
      async dialogIssuedOpen (row) {
        await AutoPromise([
          async () => {
            if (!this.DICTIONARY_shelvesTask) {
              await this.USE('DICTIONARY_shelvesTask');
            }
          },
        ]);
        this.dialogIssued.row = row;
        console.log('id:' + this.dialogIssued.row.id);
        this.dialogIssued.visible = true;
      },
      async dialogRemoteryid (id) {
        this.dialogIssued.wmsqualityinspectionlist.forEach(value => {
          if (id === value.id) {
            this.dialogIssued.row.userName = value.name;
          }
        });
      },
      dialogIssuedSave () {
        if (this.formDialogIssued.account === '0') {
          this.VALIDATE('formDialogIssued', async option => {
            delete option.account;
            option.userId = '' + option.ryid;
            delete option.ryid;
            option.userName = this.dialogIssued.row.userName;
            option.id = this.dialogIssued.row.id;
            try {
              await this.post('/wmsartificialreplenishment/addBhRw', option);
              this.dialogIssuedInit();
              this.tableWatch('table');
              this.dialogIssued.visible = false;
            } catch (err) {
              console.log(err);
            }
          });
        } else {
          this.VALIDATE('formDialogIssued', async option => {
            delete option.account;
            option.userId = '' + option.ryid;
            delete option.ryid;
            option.userName = this.dialogIssued.row.userName;
            option.id = this.dialogIssued.row.id;
            try {
              await this.post('/wmsartificialreplenishment/addBhRw', option);
              this.dialogIssuedInit();
              this.tableWatch('table');
              this.dialogIssued.visible = false;
            } catch (err) {
              console.log(err);
            }
          });
        }
      },
      dialogReplenishmentInit () {},
      dialogReplenishmentOpen (row) {
        this.tableReplenishment.url = '/wmspdareplenishment/list';
        this.tableReplenishment.option.bhlx = '1';
        this.tableReplenishment.option.bhid = row.id;
        this.tableWatch('tableReplenishment');
        this.dialogReplenishment.visible = true;
      },
    },
    watch: {
      'formDialogIssued.account': async function (account) {
        this.formDialogIssued.ryid = '';
        if (account.length !== 0 && account === '0') {
          this.dialogIssued.wmsqualityinspectionlist = await this.post('/wmsqualityinspectionlist/selectYh', {});
        }
        if (account.length !== 0 && account === '1') {
          let {contentList} = await this.post('/wmsqualityinspectionlist/selectPDADLByHz', {
          });
          this.dialogIssued.wmsqualityinspectionlist = contentList;
        }
      },
    },
    mounted: async function () {
      this.tableWatch('table');
      if (!this.DICTIONARY_artificialReplenishment) {
        await this.USE('DICTIONARY_artificialReplenishment');
      }
    },
  });
</script>
<style scoped lang="scss">
  .box-card {
    margin: 20px;
  }

  .createTimeSpan {
    display: block;
    margin-top: 34px;
  }

  @media screen and (max-width: 800px) {
    .createTimeSpan {
      margin-top: 0;
    }
    .box-card {
      margin: 0;
    }
  }

  .el-select {
    width: 100%;
  }
</style>

<style lang="scss">
  .artificialReplenishment{
    width: 88vw;
    float: left;
  }
</style>
